﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AG.Data
{
    public class AGMap
    {
        public AGMapTile[] Tiles { get; set; }

        public ushort Row { get; set; }
        public ushort Col { get; set; }

        public ushort Id { get; set; }
        public string Name { get; set; }

        public List<AGMapObject> ObjectList { get; set; }

        public uint _objId { get; set; }

        public List<AGMapSwitchPoint> SwitchPoints { get; set; }

        public AGMap()
        {
            ObjectList = new List<AGMapObject>();
            SwitchPoints = new List<AGMapSwitchPoint>();
        }

        public AGMapTile GetTile(int row, int col)
        {
            if (row < 0)
            {
                row = 0;
            }

            if (col < 0)
            {
                col = 0;
            }

            return Tiles[row * Col + col];
        }

        /// <summary>
        /// 从地图目前所有的单位中寻找最大的单位编号
        /// </summary>
        public void ValidateMaxObjectId()
        {
            for (int index = 0; index < ObjectList.Count; index++)
            {
                if (_objId < ObjectList[index].Id)
                {
                    _objId = ObjectList[index].Id;
                }
            }
        }

        public uint GetObjId()
        {
            _objId++;
            return _objId;
        }
    }
}
